﻿using System;

namespace EpiNEXT.Core.Validation.Functions
{
    public sealed class Days : DateDiffBase
    {
        public Days()
            : base()
        {

        }

        public override object Execute(Record record, params object[] parameters)
        {
            object result = base.Execute(record, parameters);

            if (result == null)
            {
                return result;
            }
            else
            {
                TimeSpan span = EndDate.Value.Subtract(StartDate.Value);
                return (int)span.TotalDays;
            }
        }
    }
}
